<?php
/**
 * My new Zend Framework project
 * 
 * @author  
 * @version 
 */

require_once 'Zend/Controller/Plugin/Abstract.php';
require_once 'Zend/Controller/Front.php';
require_once 'Zend/Controller/Request/Abstract.php';
require_once 'Zend/Controller/Action/HelperBroker.php';

/**
 * 
 * Initializes configuration depndeing on the type of environment 
 * (test, development, production, etc.)
 *  
 * This can be used to configure environment variables, databases, 
 * layouts, routers, helpers and more
 *   
 */
class Initializer extends Zend_Controller_Plugin_Abstract
{
    /**
     * @var Zend_Config
     */
    protected static $_config;

    /**
     * @var string Current environment
     */
    protected $_env;

    /**
     * @var Zend_Controller_Front
     */
    protected $_front;

    /**
     * @var string Path to application root
     */
    protected $_root;
    
    public static $registry = null;
    
    public static $translate = null;
    public static $root = null;
    
    /**
     * Constructor
     *
     * Initialize environment, root path, and configuration.
     * 
     * @param  string $env 
     * @param  string|null $root 
     * @return void
     */
    public function __construct($env, $root = null)
    {
        $this->_setEnv($env);
        if (null === $root) {
            $root = realpath(dirname(__FILE__) . '/../');
        }
        $this->_root = $root;
		$this->root = $root;
        $this->initPhpConfig();
        
        $this->_front = Zend_Controller_Front::getInstance();
        
        // set the test environment parameters
        if ($env == 'test') {
			// Enable all errors so we'll know when something goes wrong. 
			error_reporting(E_ALL | E_STRICT);  
			ini_set('display_startup_errors', 1);  
			ini_set('display_errors', 1); 
			$this->_front->throwExceptions(true);  
        }
    }

    /**
     * Initialize environment
     * 
     * @param  string $env 
     * @return void
     */
    protected function _setEnv($env) 
    {
		$this->_env = $env;    	
    }
    

    /**
     * Initialize Data bases
     * 
     * @return void
     */
    public function initPhpConfig()
    {
    	error_reporting(E_ALL|E_STRICT);
        ini_set('display_errors', true);
        date_default_timezone_set('Asia/Shanghai');
        self::$root = dirname(dirname(__FILE__));
        // htmlpurifier constant
        define('HTMLPURIFIER_PREFIX', self::$root . '/library');
    }
    
    /**
     * Route startup
     * 
     * @return void
     */
    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {  
    	self::$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
    	Zend_Registry::setInstance(self::$registry);
        $config = new Zend_Config_Ini(
            self::$root . '/config/config.ini',
            'general'
        );
        self::$registry->configuration = $config;
        Zend_Registry::set('rootPath',$config->general->rootpath);      
       	$this->initDb(); 
        $this->initHelpers();
        $this->initView();
        $this->initPlugins();
        $this->initRoutes();
        $this->initControllers();        
        $this->initAcl(); 
        $this->initLanguage();
        
        $this->initConstants();      
    }

    public function initConstants()
    {    	
    	$translate = Zend_Registry::get('translate');
    	$languages = array(
    		"en"=>$translate->_('english'), 
    		"zh"=>$translate->_('chinese'),
    		"de"=>$translate->_('german'),
    		"nl"=>$translate->_('dutch'),
    		"fr"=>$translate->_('french'),
    		"es"=>$translate->_('spanish'),
//    		"it"=>$translate->_('italian'),
    	); 
    	Zend_Registry::set('languages', $languages);
	
    	$status = array(
				array('Status' => '0', 'Description' => $translate->_('active')),
				array('Status' => '1', 'Description' => $translate->_('inactive'))
			);
    	
    	Zend_Registry::set('status', $status);
	
    	$userType = array(
				array('UserType' => '3', 'Description' => $translate->_('assistant')),
				array('UserType' => '2', 'Description' => $translate->_('consultant')),
				array('UserType' => '1', 'Description' => $translate->_('administrator'))
			);
    	
    	Zend_Registry::set('userTypes', $userType);
	
    	$gender = array(
				array('Gender' => 'M', 'Description' => $translate->_('male')),
				array('Gender' => 'F', 'Description' => $translate->_('female'))
			);
    	
    	Zend_Registry::set('gender', $gender);
    	
    	$title = array(
    		'unknown' => $translate->_('unknown'),
			'mr'   => $translate->_('mr'),
			'miss' => $translate->_('miss'),
			'mrs'  => $translate->_('mrs'),
			'ms'   => $translate->_('ms')
    	);
    	Zend_Registry::set('title', $title);

    	$sex = array(
    		'N'	=> $translate->_('unknown'),
			'M' => $translate->_('male'),
			'F' => $translate->_('female')
    	);
    	Zend_Registry::set('sex', $sex);
	}
    
    /**
     * Initialize data bases
     * 
     * @return void
     */
    public function initDb()
    {
    	$config = self::$registry->configuration;
        $db = Zend_Db::factory($config->db->adapter, $config->db->toArray());
        $db->query("SET NAMES 'utf8'");
        self::$registry->database = $db;
        Zend_Db_Table::setDefaultAdapter($db);
    }

    /**
     * Initialize action helpers
     * 
     * @return void
     */
    public function initHelpers()
    {
    	// register the default action helpers
    	Zend_Controller_Action_HelperBroker::addPath('../application/default/helpers', 'Zend_Controller_Action_Helper');
    }
    
    /**
     * Initialize view 
     * 
     * @return void
     */
    public function initView()
    {
		// Bootstrap layouts
		$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
        $viewRenderer->initView();
        $viewRenderer->view->doctype('XHTML1_STRICT');
        $viewRenderer->view->setEncoding('UTF-8');
        $viewRenderer->view->addHelperPath(
            self::$root . '/library/Dhr/View/Helper',
            'Dhr_View_Helper'
        ); 
    	
		Zend_Layout::startMvc(array(
		    'layoutPath' => $this->_root .  '/application/default/layouts/default',
		    'layout' => 'main',
			'pluginClass' => 'Dhr_Layout_Controller_Plugin_Layout'
		));
    	
    }
    
    /**
     * Initialize plugins 
     * 
     * @return void
     */
    public function initPlugins()
    {
    	
    }
    
    /**
     * Initialize routes
     * 
     * @return void
     */
    public function initRoutes()
    {
    	$router = $this->_front->getRouter();
    	
        $emailTemplateRoute = new Zend_Controller_Router_Route('template/view/:ref',
		    array('controller'=>'template', 'action'=>'view')
		);   
		$router->addRoute('emailTemplate', $emailTemplateRoute);

        $emailTemplateEditRoute = new Zend_Controller_Router_Route('template/edit/:id',
		    array('controller'=>'template', 'action'=>'edit')
		);   
		$router->addRoute('emailTemplateEdit', $emailTemplateEditRoute);
		
        $emailTemplateDeleteRoute = new Zend_Controller_Router_Route('template/delete/:ref',
		    array('controller'=>'template', 'action'=>'delete')
		);   
		$router->addRoute('emailTemplateDelete', $emailTemplateDeleteRoute);
		
        $categoryProfessionalRoute = new Zend_Controller_Router_Route('categoryProfessional/view/:id',
		    array('controller'=>'categoryProfessional', 'action'=>'view')
		);   
		$router->addRoute('categoryProfessional', $categoryProfessionalRoute);

        $categoryProfessionalEditRoute = new Zend_Controller_Router_Route('categoryprofessional/edit/:id',
		    array('controller'=>'categoryprofessional', 'action'=>'edit')
		);   
		$router->addRoute('categoryProfessionalEdit', $categoryProfessionalEditRoute);
		
        $categoryProfessionalDeleteRoute = new Zend_Controller_Router_Route('categoryprofessional/delete/:reference',
		    array('controller'=>'categoryprofessional', 'action'=>'delete')
		);   
		$router->addRoute('categoryProfessionalDelete', $categoryProfessionalDeleteRoute);
		
        $categoryTemplateDeleteRoute = new Zend_Controller_Router_Route('categorytemplate/delete/:reference',
		    array('controller'=>'categorytemplate', 'action'=>'delete')
		);   
		$router->addRoute('categoryTemplateDelete', $categoryTemplateDeleteRoute);
		
        $categoryTemplateEditRoute = new Zend_Controller_Router_Route('categorytemplate/edit/:id',
		    array('controller'=>'categorytemplate', 'action'=>'edit')
		);   
		$router->addRoute('categoryTemplateEdit', $categoryTemplateEditRoute);
		
        $cityDeleteRoute = new Zend_Controller_Router_Route('city/delete/:reference',
		    array('controller'=>'city', 'action'=>'delete')
		);   
		$router->addRoute('cityDelete', $cityDeleteRoute);
		
        $cityEditRoute = new Zend_Controller_Router_Route('city/edit/:id',
		    array('controller'=>'city', 'action'=>'edit')
		);   
		$router->addRoute('cityEdit', $cityEditRoute);
		
        $countryDeleteRoute = new Zend_Controller_Router_Route('country/delete/:reference',
		    array('controller'=>'country', 'action'=>'delete')
		);   
		$router->addRoute('countryDelete', $countryDeleteRoute);
		
        $countryEditRoute = new Zend_Controller_Router_Route('country/edit/:id',
		    array('controller'=>'country', 'action'=>'edit')
		);   
		$router->addRoute('countryEdit', $countryEditRoute);
		
        $provinceDeleteRoute = new Zend_Controller_Router_Route('province/delete/:reference',
		    array('controller'=>'province', 'action'=>'delete')
		);   
		$router->addRoute('provinceDelete', $provinceDeleteRoute);
		
        $provinceEditRoute = new Zend_Controller_Router_Route('province/edit/:id',
		    array('controller'=>'province', 'action'=>'edit')
		);   
		$router->addRoute('provinceEdit', $provinceEditRoute);
		
        $ethnicityDeleteRoute = new Zend_Controller_Router_Route('ethnicity/delete/:reference',
		    array('controller'=>'ethnicity', 'action'=>'delete')
		);   
		$router->addRoute('ethnicityDelete', $ethnicityDeleteRoute);
		
        $ethnicityEditRoute = new Zend_Controller_Router_Route('ethnicity/edit/:id',
		    array('controller'=>'ethnicity', 'action'=>'edit')
		);   
		$router->addRoute('ethnicityEdit', $ethnicityEditRoute);
		
        $statusDeleteRoute = new Zend_Controller_Router_Route('paymentstatus/delete/:reference',
		    array('controller'=>'paymentstatus', 'action'=>'delete')
		);   
		$router->addRoute('statusDelete', $statusDeleteRoute);
		
        $statusEditRoute = new Zend_Controller_Router_Route('paymentstatus/edit/:id',
		    array('controller'=>'paymentstatus', 'action'=>'edit')
		);   
		$router->addRoute('statusEdit', $statusEditRoute);
		
        $maritalDeleteRoute = new Zend_Controller_Router_Route('maritalstatus/delete/:reference',
		    array('controller'=>'maritalstatus', 'action'=>'delete')
		);   
		$router->addRoute('maritalDelete', $maritalDeleteRoute);
		
        $maritalEditRoute = new Zend_Controller_Router_Route('maritalstatus/edit/:id',
		    array('controller'=>'maritalstatus', 'action'=>'edit')
		);   
		$router->addRoute('maritalEdit', $maritalEditRoute);
		
        $searchTypeDeleteRoute = new Zend_Controller_Router_Route('searchtype/delete/:reference',
		    array('controller'=>'searchtype', 'action'=>'delete')
		);   
		$router->addRoute('searchTypeDelete', $searchTypeDeleteRoute);
		
        $searchTypeEditRoute = new Zend_Controller_Router_Route('searchtype/edit/:id',
		    array('controller'=>'searchtype', 'action'=>'edit')
		);   
		$router->addRoute('searchTypeEdit', $searchTypeEditRoute);
		
        $levelDeleteRoute = new Zend_Controller_Router_Route('careerlevel/delete/:reference',
		    array('controller'=>'careerlevel', 'action'=>'delete')
		);   
		$router->addRoute('levelDelete', $levelDeleteRoute);
		
        $levelEditRoute = new Zend_Controller_Router_Route('careerlevel/edit/:id',
		    array('controller'=>'careerlevel', 'action'=>'edit')
		);   
		$router->addRoute('levelEdit', $levelEditRoute);
		
        $positionDeleteRoute = new Zend_Controller_Router_Route('position/delete/:reference',
		    array('controller'=>'position', 'action'=>'delete')
		);   
		$router->addRoute('positionDelete', $positionDeleteRoute);
		
        $positionEditRoute = new Zend_Controller_Router_Route('position/edit/:id',
		    array('controller'=>'position', 'action'=>'edit')
		);   
		$router->addRoute('positionEdit', $positionEditRoute);
		
        $languageDeleteRoute = new Zend_Controller_Router_Route('language/delete/:reference',
		    array('controller'=>'language', 'action'=>'delete')
		);   
		$router->addRoute('languageDelete', $languageDeleteRoute);
		
        $languageEditRoute = new Zend_Controller_Router_Route('language/edit/:id',
		    array('controller'=>'language', 'action'=>'edit')
		);   
		$router->addRoute('languageEdit', $languageEditRoute);
		
        $industryDeleteRoute = new Zend_Controller_Router_Route('industry/delete/:reference',
		    array('controller'=>'industry', 'action'=>'delete')
		);   
		$router->addRoute('industryDelete', $industryDeleteRoute);
		
        $industryEditRoute = new Zend_Controller_Router_Route('industry/edit/:id',
		    array('controller'=>'industry', 'action'=>'edit')
		);   
		$router->addRoute('industryEdit', $industryEditRoute);
		
        $stageDeleteRoute = new Zend_Controller_Router_Route('stage/delete/:reference',
		    array('controller'=>'stage', 'action'=>'delete')
		);   
		$router->addRoute('stageDelete', $stageDeleteRoute);
		
        $stageEditRoute = new Zend_Controller_Router_Route('stage/edit/:id',
		    array('controller'=>'stage', 'action'=>'edit')
		);   
		$router->addRoute('stageEdit', $stageEditRoute);
		
        $tstatusDeleteRoute = new Zend_Controller_Router_Route('trajectorystatus/delete/:reference',
		    array('controller'=>'trajectorystatus', 'action'=>'delete')
		);   
		$router->addRoute('tstatusDelete', $tstatusDeleteRoute);
		
        $tstatusEditRoute = new Zend_Controller_Router_Route('trajectorystatus/edit/:id',
		    array('controller'=>'trajectorystatus', 'action'=>'edit')
		);   
		$router->addRoute('tstatusEdit', $tstatusEditRoute);
		
        $fareaDeleteRoute = new Zend_Controller_Router_Route('functionalarea/delete/:reference',
		    array('controller'=>'functionalarea', 'action'=>'delete')
		);   
		$router->addRoute('fareaDelete', $fareaDeleteRoute);
		
        $fareaEditRoute = new Zend_Controller_Router_Route('functionalarea/edit/:id',
		    array('controller'=>'functionalarea', 'action'=>'edit')
		);   
		$router->addRoute('fareaEdit', $fareaEditRoute);
		
        $currentStatusDeleteRoute = new Zend_Controller_Router_Route('currentstatus/delete/:reference',
		    array('controller'=>'currentstatus', 'action'=>'delete')
		);   
		$router->addRoute('currentStatusDelete', $currentStatusDeleteRoute);
		
        $currentStatusEditRoute = new Zend_Controller_Router_Route('currentstatus/edit/:id',
		    array('controller'=>'currentstatus', 'action'=>'edit')
		);   
		$router->addRoute('currentstatusEdit', $currentStatusEditRoute);
		
        $emailTypeDeleteRoute = new Zend_Controller_Router_Route('emailtype/delete/:reference',
		    array('controller'=>'emailtype', 'action'=>'delete')
		);   
		$router->addRoute('emailTypeDelete', $emailTypeDeleteRoute);
		
        $emailTypeEditRoute = new Zend_Controller_Router_Route('emailtype/edit/:id',
		    array('controller'=>'emailtype', 'action'=>'edit')
		);   
		$router->addRoute('emailTypeEdit', $emailTypeEditRoute);
		
        $educationDeleteRoute = new Zend_Controller_Router_Route('education/delete/:reference',
		    array('controller'=>'education', 'action'=>'delete')
		);   
		$router->addRoute('educationDelete', $educationDeleteRoute);
		
        $educationEditRoute = new Zend_Controller_Router_Route('education/edit/:id',
		    array('controller'=>'education', 'action'=>'edit')
		);   
		$router->addRoute('educationEdit', $educationEditRoute);
		
        $employmentTypeDeleteRoute = new Zend_Controller_Router_Route('employmenttype/delete/:reference',
		    array('controller'=>'employmenttype', 'action'=>'delete')
		);   
		$router->addRoute('employmentTypeDelete', $employmentTypeDeleteRoute);
		
        $employmentTypeEditRoute = new Zend_Controller_Router_Route('employmenttype/edit/:id',
		    array('controller'=>'employmenttype', 'action'=>'edit')
		);   
		$router->addRoute('employmentTypeEdit', $employmentTypeEditRoute);
		
        $targetSalaryDeleteRoute = new Zend_Controller_Router_Route('targetsalary/delete/:reference',
		    array('controller'=>'targetsalary', 'action'=>'delete')
		);   
		$router->addRoute('targetSalaryDelete', $targetSalaryDeleteRoute);
		
        $targetSalaryEditRoute = new Zend_Controller_Router_Route('targetsalary/edit/:id',
		    array('controller'=>'targetsalary', 'action'=>'edit')
		);   
		$router->addRoute('targetSalaryEdit', $targetSalaryEditRoute);
		
        $companyTypeDeleteRoute = new Zend_Controller_Router_Route('companytype/delete/:reference',
		    array('controller'=>'companytype', 'action'=>'delete')
		);   
		$router->addRoute('companyTypeDelete', $companyTypeDeleteRoute);
		
        $companyTypeEditRoute = new Zend_Controller_Router_Route('companytype/edit/:id',
		    array('controller'=>'companytype', 'action'=>'edit')
		);   
		$router->addRoute('companyTypeEdit', $companyTypeEditRoute);
		
        $companySizeDeleteRoute = new Zend_Controller_Router_Route('companysize/delete/:reference',
		    array('controller'=>'companysize', 'action'=>'delete')
		);   
		$router->addRoute('companySizeDelete', $companySizeDeleteRoute);
		
        $companySizeEditRoute = new Zend_Controller_Router_Route('companysize/edit/:id',
		    array('controller'=>'companysize', 'action'=>'edit')
		);   
		$router->addRoute('companySizeEdit', $companySizeEditRoute);
		
        $referenceTypeDeleteRoute = new Zend_Controller_Router_Route('referencetype/delete/:reference',
		    array('controller'=>'referencetype', 'action'=>'delete')
		);   
		$router->addRoute('referenceTypeDelete', $referenceTypeDeleteRoute);
		
        $referenceTypeEditRoute = new Zend_Controller_Router_Route('referencetype/edit/:id',
		    array('controller'=>'referencetype', 'action'=>'edit')
		);   
		$router->addRoute('referenceTypeEdit', $referenceTypeEditRoute);
		
        $degreeNameDeleteRoute = new Zend_Controller_Router_Route('degreename/delete/:reference',
		    array('controller'=>'degreename', 'action'=>'delete')
		);   
		$router->addRoute('degreeNameDelete', $degreeNameDeleteRoute);
		
        $degreeNameEditRoute = new Zend_Controller_Router_Route('degreename/edit/:id',
		    array('controller'=>'degreename', 'action'=>'edit')
		);   
		$router->addRoute('degreeNameEdit', $degreeNameEditRoute);
		
        $degreeTitleDeleteRoute = new Zend_Controller_Router_Route('degreetitle/delete/:reference',
		    array('controller'=>'degreetitle', 'action'=>'delete')
		);   
		$router->addRoute('degreeTitleDelete', $degreeTitleDeleteRoute);
		
        $degreeTitleEditRoute = new Zend_Controller_Router_Route('degreetitle/edit/:id',
		    array('controller'=>'degreetitle', 'action'=>'edit')
		);   
		$router->addRoute('degreeTitleEdit', $degreeTitleEditRoute);
		
        $educationStatusDeleteRoute = new Zend_Controller_Router_Route('educationstatus/delete/:reference',
		    array('controller'=>'educationstatus', 'action'=>'delete')
		);   
		$router->addRoute('educationStatusDelete', $educationStatusDeleteRoute);
		
        $educationStatusDeleteRoute = new Zend_Controller_Router_Route('educationstatus/edit/:id',
		    array('controller'=>'educationstatus', 'action'=>'edit')
		);   
		$router->addRoute('educationStatusEdit', $educationStatusDeleteRoute);
		
        $itSkillDeleteRoute = new Zend_Controller_Router_Route('itskill/delete/:reference',
		    array('controller'=>'itskill', 'action'=>'delete')
		);   
		$router->addRoute('itSkillDelete', $itSkillDeleteRoute);
		
        $itSkillEditRoute = new Zend_Controller_Router_Route('itskill/edit/:id',
		    array('controller'=>'itskill', 'action'=>'edit')
		);   
		$router->addRoute('itSkillEdit', $itSkillEditRoute);
		
        $otherSkillCertificationDeleteRoute = new Zend_Controller_Router_Route('otherskillcertification/delete/:reference',
		    array('controller'=>'otherskillcertification', 'action'=>'delete')
		);   
		$router->addRoute('otherSkillCertificationDelete', $otherSkillCertificationDeleteRoute);
		
        $otherSkillCertificationEditRoute = new Zend_Controller_Router_Route('otherskillcertification/edit/:id',
		    array('controller'=>'otherskillcertification', 'action'=>'edit')
		);   
		$router->addRoute('otherSkillCertificationEdit', $otherSkillCertificationEditRoute);
		
        $otherSkillDeleteRoute = new Zend_Controller_Router_Route('otherskill/delete/:reference',
		    array('controller'=>'otherskill', 'action'=>'delete')
		);   
		$router->addRoute('otherSkillDelete', $otherSkillDeleteRoute);
		
        $otherSkillEditRoute = new Zend_Controller_Router_Route('otherskill/edit/:id',
		    array('controller'=>'otherskill', 'action'=>'edit')
		);   
		$router->addRoute('otherSkillEdit', $otherSkillEditRoute);
		
        $skillLevelDeleteRoute = new Zend_Controller_Router_Route('skilllevel/delete/:reference',
		    array('controller'=>'skilllevel', 'action'=>'delete')
		);   
		$router->addRoute('skillLevelDelete', $skillLevelDeleteRoute);
			
        $skillLevelEditRoute = new Zend_Controller_Router_Route('skilllevel/edit/:id',
		    array('controller'=>'skilllevel', 'action'=>'edit')
		);   
		$router->addRoute('skillLevelEdit', $skillLevelEditRoute);
		
        $oralLevelDeleteRoute = new Zend_Controller_Router_Route('orallevel/delete/:reference',
		    array('controller'=>'orallevel', 'action'=>'delete')
		);   
		$router->addRoute('oralLevelDelete', $oralLevelDeleteRoute);
			
        $oralLevelEditRoute = new Zend_Controller_Router_Route('orallevel/edit/:id',
		    array('controller'=>'orallevel', 'action'=>'edit')
		);   
		$router->addRoute('oralLevelEdit', $oralLevelEditRoute);
		
        $comprehensionLevelDeleteRoute = new Zend_Controller_Router_Route('comprehensionlevel/delete/:reference',
		    array('controller'=>'comprehensionlevel', 'action'=>'delete')
		);   
		$router->addRoute('comprehensionLevelDelete', $comprehensionLevelDeleteRoute);
			
        $comprehensionLevelEditRoute = new Zend_Controller_Router_Route('comprehensionlevel/edit/:id',
		    array('controller'=>'comprehensionlevel', 'action'=>'edit')
		);   
		$router->addRoute('comprehensionLevelEdit', $comprehensionLevelEditRoute);
		
        $writingLevelDeleteRoute = new Zend_Controller_Router_Route('writinglevel/delete/:reference',
		    array('controller'=>'writinglevel', 'action'=>'delete')
		);   
		$router->addRoute('writingLevelDelete', $writingLevelDeleteRoute);
			
        $writingLevelEditRoute = new Zend_Controller_Router_Route('writinglevel/edit/:id',
		    array('controller'=>'writinglevel', 'action'=>'edit')
		);   
		$router->addRoute('writingLevelEdit', $writingLevelEditRoute);
		
        $languageLevelDeleteRoute = new Zend_Controller_Router_Route('languagelevel/delete/:reference',
		    array('controller'=>'languagelevel', 'action'=>'delete')
		);   
		$router->addRoute('languageLevelDelete', $languageLevelDeleteRoute);
			
        $languageLevelEditRoute = new Zend_Controller_Router_Route('languagelevel/edit/:id',
		    array('controller'=>'languagelevel', 'action'=>'edit')
		);   
		$router->addRoute('languageLevelEdit', $languageLevelEditRoute);
		
		$languageCertificateDeleteRoute = new Zend_Controller_Router_Route('languagecertificate/delete/:reference',
		    array('controller'=>'languagecertificate', 'action'=>'delete')
		);   
		$router->addRoute('languageCertificateDelete', $languageCertificateDeleteRoute);
			
        $languageCertificateEditRoute = new Zend_Controller_Router_Route('languagecertificate/edit/:id',
		    array('controller'=>'languagecertificate', 'action'=>'edit')
		);   
		$router->addRoute('languageCertificateEdit', $languageCertificateEditRoute);
		
		$clientDeleteRoute = new Zend_Controller_Router_Route('client/delete/:reference',
		    array('controller'=>'client', 'action'=>'delete')
		);   
		$router->addRoute('clientDelete', $clientDeleteRoute);
			
        $clientEditRoute = new Zend_Controller_Router_Route('client/edit/:id',
		    array('controller'=>'client', 'action'=>'edit')
		);   
		$router->addRoute('clientEdit', $clientEditRoute);
		
		$priorityDeleteRoute = new Zend_Controller_Router_Route('priority/delete/:reference',
		    array('controller'=>'priority', 'action'=>'delete')
		);   
		$router->addRoute('priorityDelete', $priorityDeleteRoute);
			
        $priorityEditRoute = new Zend_Controller_Router_Route('priority/edit/:id',
		    array('controller'=>'priority', 'action'=>'edit')
		);   
		$router->addRoute('priorityEdit', $priorityEditRoute);
		
        $attachmentTypeDeleteRoute = new Zend_Controller_Router_Route('attachmenttype/delete/:reference',
		    array('controller'=>'attachmenttype', 'action'=>'delete')
		);   
		$router->addRoute('attachmentTypeDelete', $attachmentTypeDeleteRoute);
		
        $attachmentTypeEditRoute = new Zend_Controller_Router_Route('attachmenttype/edit/:id',
		    array('controller'=>'attachmenttype', 'action'=>'edit')
		);   
		$router->addRoute('attachmentTypeEdit', $attachmentTypeEditRoute);
		
        $attachmentTypeSTDeleteRoute = new Zend_Controller_Router_Route('attachmenttypest/delete/:reference',
		    array('controller'=>'attachmenttypest', 'action'=>'delete')
		);   
		$router->addRoute('attachmentTypeSTDelete', $attachmentTypeSTDeleteRoute);
		
        $attachmentTypeSTEditRoute = new Zend_Controller_Router_Route('attachmenttypest/edit/:id',
		    array('controller'=>'attachmenttypest', 'action'=>'edit')
		);   
		$router->addRoute('attachmentTypeSTEdit', $attachmentTypeSTEditRoute);
		
        $recruitmentProcessDeleteRoute = new Zend_Controller_Router_Route('recruitmentprocess/delete/:reference',
		    array('controller'=>'recruitmentprocess', 'action'=>'delete')
		);   
		$router->addRoute('recruitmentProcessDelete', $recruitmentProcessDeleteRoute);
		
        $recruitmentProcessEditRoute = new Zend_Controller_Router_Route('recruitmentprocess/edit/:id',
		    array('controller'=>'recruitmentprocess', 'action'=>'edit')
		);   
		$router->addRoute('recruitmentProcessEdit', $recruitmentProcessEditRoute);
		
        $professionalStatusDeleteRoute = new Zend_Controller_Router_Route('professionalstatus/delete/:reference',
		    array('controller'=>'professionalstatus', 'action'=>'delete')
		);   
		$router->addRoute('professionalStatusDelete', $professionalStatusDeleteRoute);
		
        $professionalStatusEditRoute = new Zend_Controller_Router_Route('professionalstatus/edit/:id',
		    array('controller'=>'professionalstatus', 'action'=>'edit')
		);   
		$router->addRoute('professionalStatusEdit', $professionalStatusEditRoute);
		
        $professionalSourceDeleteRoute = new Zend_Controller_Router_Route('professionalsource/delete/:reference',
		    array('controller'=>'professionalsource', 'action'=>'delete')
		);   
		$router->addRoute('professionalSourceDelete', $professionalSourceDeleteRoute);
		
        $professionalSourceEditRoute = new Zend_Controller_Router_Route('professionalsource/edit/:id',
		    array('controller'=>'professionalsource', 'action'=>'edit')
		);   
		$router->addRoute('professionalSourceEdit', $professionalSourceEditRoute);
		
        $hukouDeleteRoute = new Zend_Controller_Router_Route('hukou/delete/:reference',
		    array('controller'=>'hukou', 'action'=>'delete')
		);   
		$router->addRoute('hukouDelete', $hukouDeleteRoute);
		
        $hukouEditRoute = new Zend_Controller_Router_Route('hukou/edit/:id',
		    array('controller'=>'hukou', 'action'=>'edit')
		);   
		$router->addRoute('hukouEdit', $hukouEditRoute);
		
        $skillCertificationDeleteRoute = new Zend_Controller_Router_Route('skillcertification/delete/:reference',
		    array('controller'=>'skillcertification', 'action'=>'delete')
		);   
		$router->addRoute('skillCertificationDelete', $skillCertificationDeleteRoute);
		
        $skillCertificationEditRoute = new Zend_Controller_Router_Route('skillcertification/edit/:id',
		    array('controller'=>'skillcertification', 'action'=>'edit')
		);   
		$router->addRoute('skillCertificationEdit', $skillCertificationEditRoute);
		
        $titleDeleteRoute = new Zend_Controller_Router_Route('title/delete/:reference',
		    array('controller'=>'title', 'action'=>'delete')
		);   
		$router->addRoute('titleDelete', $titleDeleteRoute);
		
        $titleEditRoute = new Zend_Controller_Router_Route('title/edit/:id',
		    array('controller'=>'title', 'action'=>'edit')
		);   
		$router->addRoute('titleEdit', $titleEditRoute);
		
        $citizenshipDeleteRoute = new Zend_Controller_Router_Route('citizenship/delete/:reference',
		    array('controller'=>'citizenship', 'action'=>'delete')
		);   
		$router->addRoute('citizenshipDelete', $citizenshipDeleteRoute);
		
        $citizenshipEditRoute = new Zend_Controller_Router_Route('citizenship/edit/:id',
		    array('controller'=>'citizenship', 'action'=>'edit')
		);   
		$router->addRoute('citizenshipEdit', $citizenshipEditRoute);
		
		//user action router
        $userEditRoute = new Zend_Controller_Router_Route('user/edit/:id',
		    array('controller'=>'user', 'action'=>'edit')
		);   
		$router->addRoute('userEdit',$userEditRoute);
		
		$userDeleteRoute = new Zend_Controller_Router_Route('user/delete/:id',
			array('controller' => 'user', 'action' => 'delete')
		);
		$router->addRoute('userDelete',$userDeleteRoute);
		
		// search trajectory
        $trajectoryEditRoute = new Zend_Controller_Router_Route('trajectory/edit/:id',
		    array('controller'=>'trajectory', 'action'=>'edit')
		);   
		$router->addRoute('trajectoryEdit',$trajectoryEditRoute);
		
		$trajectoryDeleteRoute = new Zend_Controller_Router_Route('trajectory/delete/:id',
			array('controller' => 'trajectory', 'action' => 'delete')
		);
		$router->addRoute('trajectoryDelete',$trajectoryDeleteRoute);		
		
		// professional pdf
		$pdfProfessionalRoute = new Zend_Controller_Router_Route('pdf/professional/:pro_id/:isopen',
		    array('controller'=>'pdf', 'action'=>'professional')
		); 
		$router->addRoute('pdfJob', $pdfProfessionalRoute); 
		//-- professional resume
        $professionalEditRoute = new Zend_Controller_Router_Route('professional/edit/:id',
		    array('controller'=>'professional', 'action'=>'edit')
		);   
		$router->addRoute('professionalEdit',$professionalEditRoute);
		
		$professionalDeleteRoute = new Zend_Controller_Router_Route('professional/delete/:id',
			array('controller' => 'professional', 'action' => 'delete')
		);
		$router->addRoute('professionalDelete',$professionalDeleteRoute);
						
		//-- add router for categoryQuestion
		$attachmentDownloadRouter = new Zend_Controller_Router_Route('professional/download/:id',
			array('controller' => 'professional', 'action' => 'download')
		);
		$router->addRoute('attachmentDownload',$attachmentDownloadRouter);
		
		$categoryQuestionRouter = new Zend_Controller_Router_Route('categoryquestion/add/:id',
			array('controller' => 'categoryquestion', 'action' => 'add')
		);
		$router->addRoute('categoryQuestionAdd',$categoryQuestionRouter);
		
		$categoryQuestionRouter = new Zend_Controller_Router_Route('categoryquestion/edit/:id',
			array('controller' => 'categoryquestion', 'action' => 'edit')
		);
		$router->addRoute('categoryQuestionEdit',$categoryQuestionRouter);
		
		$categoryQuestionRouter = new Zend_Controller_Router_Route('categoryquestion/delete/:id',
			array('controller' => 'categoryquestion', 'action' => 'delete')
		);
		$router->addRoute('categoryQuestionDelete',$categoryQuestionRouter);

		$QuestionRouter = new Zend_Controller_Router_Route('question/delete/:id',
			array('controller' => 'question', 'action' => 'delete')
		);
		$router->addRoute('QuestioIndex',$QuestionRouter);
		
		$QuestionRouter = new Zend_Controller_Router_Route('question/index/:id',
			array('controller' => 'question', 'action' => 'index')
		);
		$router->addRoute('QuestioIndex',$QuestionRouter);
		//--
    }

    /**
     * Initialize Controller paths 
     * 
     * @return void
     */
    public function initControllers()
    {
    	$this->_front->addControllerDirectory($this->_root . '/application/default/controllers', 'default');
    }
    
    public function initAcl()
    {
        $auth = Zend_Auth::getInstance();
        $acl = new Dhr_Acl($auth);
        $this->_front->setParam('auth', $auth);
        $this->_front->setParam('acl', $acl);
        $this->_front->registerPlugin(
            new Dhr_Controller_Plugin_Acl($auth, $acl)
        );   	
    }
    
    public function initLanguage()
    {
    	$path = $this->_root .'/translate/translate.xml';
		self::$translate = new Zend_Translate('tmx', $path);
		Zend_Registry::set('translate', self::$translate);  
		
		// start up session		
		$locale = new Zend_Session_Namespace('Locale');
		
    	if (!isset($locale->language))
		{
		   $locale->language= 'en';
		   self::$translate->setLocale($locale->language);
		}
		else
		{
			self::$translate->setLocale($locale->language);
		}	
    }
}
?>
